package org.hxyjs.dao.impl;

import org.hxyjs.dao.ReadrecordDao;
import org.hxyjs.entity.Readrecord;
import org.hxyjs.mapper.ReadrecordMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository("readrecordDao")//一般实现类不会直接生成默认对象名 而是使用 接口的默认对象名
public class ReadrecordDaoImpl implements ReadrecordDao {
    @Resource //autowired 会装配能够直接扫描到的对象  resource spring容器运行的时候才找到需要的对象  注入
    private ReadrecordMapper readrecordMapper;
    public List<Readrecord>  getAllReadrecords() throws Exception{
        return readrecordMapper.selectByExample(null);
    }

    @Override
    public Integer deleteReadrecordByRdno(String rdno)  throws Exception{
        return readrecordMapper.deleteByPrimaryKey(rdno);
    }

    @Override
    public Integer updateReadrecordByRdno(Readrecord readrecord)  throws Exception{
        return readrecordMapper.updateByPrimaryKey(readrecord);
    }

    @Override
    public Integer addReadrecord(Readrecord readrecord)  throws Exception{
        return readrecordMapper.insertSelective(readrecord);
    }

}
